package com.example.admin.service;


import com.example.admin.common.Result;
import com.example.admin.entity.ElderInfo;
import com.example.admin.mapper.ElderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ElderService {


    @Autowired
    private ElderMapper elderMapper;
    public List<ElderInfo> getElderInfoPage() {

       List<ElderInfo> elderInfoLis= elderMapper.getElderInfoPage();
       return elderInfoLis;

    }

    public Result deleteById(Integer id) {

       int count= elderMapper.deleteById(id);
        if (count == 0) {
            return Result.error("400","删除失败");
        }
        return Result.success("删除成功");
    }

    public Result addElderInfo(ElderInfo elderInfo) {

        int count=elderMapper.addElderInfo(elderInfo);
        if (count == 0) {
            return Result.error("400","新增失败");
        }
        return Result.success("新增成功");
    }

    public Result editElderInfo(ElderInfo elderInfo) {
        int count=elderMapper.editElderInfo(elderInfo);
        if (count == 0) {
            return Result.error("400","修改失败");
        }
        return Result.success("修改成功");
    }

    public List<ElderInfo> selectElderInfoByName(String name) {
       List<ElderInfo> elderInfoList= elderMapper.selectElderInfoByName(name);
       return elderInfoList;
    }
}
